package com.polito.mad.bikeponyapp.util;

import org.json.JSONException;
import org.json.JSONObject;

public class ResultMessage {

	private int statusCode;
	private String message;
	
	public static final int STATUS_OK = 0;
	public static final int STATUS_ERR_ALREADY_LOGGED_IN = 1;
	public static final int STATUS_ERR_ALREADY_LOGGED_OFF = 2;
	public static final int STATUS_ERR_PENDING_TASKS = 3;
	public static final int STATUS_ERR_REPRDERING_NOT_ALLOWED = 4;
	public static final int STATUS_ERR_INVALID_CREDENTIALS = 5;
	public static final int STATUS_ERR_UNKNOWN = -1;
	
	
	private JSONObject data;
	public ResultMessage(JSONObject result) throws JSONException {
		statusCode = result.getInt("statusCode");
		message = result.getString("message");
		data = result.optJSONObject("data");
	}
	public ResultMessage(int statusCode,String message)
	{
		this.statusCode=statusCode;
		this.message=message;
	}
	
	public int getStatusCode() {
		return statusCode;
	}
	public String getMessage() {
		return message;
	}
	public JSONObject getData() {
		return data;
	}
}
